import { Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';

/**
 *  2017-02-02 to 2017/02/02
 */
@Pipe({
    name: 'dateTrans',
})
export class DateTransform implements PipeTransform {
    transform(value: string | number, format="YYYY/MM/DD") {

        const result = moment(value).format(format);

        if (result != 'Invalid date') {
            return result;
        } else {
            return '';
        }
    }
}
